<template>
  <!--新增借款人信息-->
  <div>
    <el-row>
      <el-col :span="22" :offset="1" >

        <el-card class="box-card" shadow="always" style="padding: 0 15px;">

          <el-row>
            <el-col :span="24" :offset="0" style="margin-top:10px;border: 1px solid white">

              <el-form :label-position="labelPosition" :inline="true" :model="form">
                <div style="margin-bottom:-80px;border: 1px solid white">
                  <el-form-item style="width: 100%; line-height:40px;border: 1px solid white">
                    <el-divider direction="vertical" style="size:20px"></el-divider>
                    <span style="color:blue;font-size: 25px;float: left"><strong>新增借款人信息</strong></span>
                    <el-button type="primary" style="float: right;" @click="back">返回
                    </el-button>
                    <el-button type="primary" @click="onSubmit" style="float: right;margin-right: 10px">保存</el-button>
                  </el-form-item>
                </div>

                <el-form-item align="left" label="用户名" class="width270Height40">
                  <el-input v-model="form.username"></el-input>
                </el-form-item>
                <el-form-item align="left" label="密码" class="width270Height40">
                  <el-input v-model="form.password"></el-input>
                </el-form-item>
                <el-form-item align="left" label="姓名" class="width270Height40">
                  <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item align="left" label="性别" class="width270Height40">
                  <el-input v-model="form.sex"></el-input>
                </el-form-item>
                <el-form-item align="left" label="家庭地址" class="width270Height40">
                  <el-input v-model="form.address"></el-input>
                </el-form-item>
                <el-form-item align="left" label="手机号" class="width270Height40">
                  <el-input v-model="form.phone"></el-input>
                </el-form-item>
                <el-form-item align="left" label="身份证" class="width270Height40">
                  <el-input v-model="form.identitycard"></el-input>
                </el-form-item>
                <el-form-item align="left" label="邮箱" class="width270Height40">
                  <el-input v-model="form.email"></el-input>
                </el-form-item>
                <el-form-item align="left" label="角色" class="width270Height40">
                  <el-input v-model="form.role"></el-input>
                </el-form-item>
                <el-form-item align="left" label="借款开户行名称" class="width270Height40">
                  <el-input v-model="form.banknameLoan"></el-input>
                </el-form-item><br/>
                <el-form-item align="left" label="借款银行卡号" class="width270Height40">
                  <el-input v-model="form.bankcardnoLoan"></el-input>
                </el-form-item>
                <el-form-item align="left" label="信用额度" class="width270Height40">
                  <el-input v-model="form.limitnum"></el-input>
                </el-form-item>
                <el-form-item align="left" label="还款开户行名称" class="width270Height40">
                  <el-input v-model="form.banknameRepayment"></el-input>
                </el-form-item>
                <el-form-item align="left" label="还款银行卡号" class="width270Height40">
                  <el-input v-model="form.bankcardnoRepayment"></el-input>
                </el-form-item>

              </el-form>

            </el-col>
          </el-row>



        </el-card>

      </el-col>
    </el-row>
  </div>
</template>

<script>

  import axios from 'axios';
  export default {
    data() {
      return {
        labelPosition: 'top',
        form: {}
      };
    },
    methods: {
      /*onSubmit() {
        alert("保存成功")
        console.log('submit!');
      },*/
      back:function () {
        this.$router.push("/borrower")
      },
      onSubmit:function(){
        axios.post("http://localhost:9999/credit-borrower/saveOrUpdateg",this.form).then(res=>{
          this.$router.push("/borrower")
        })
      },
      findById(id){
        axios.post("http://localhost:9999/credit-borrower/findById",{id:id}).then(res=>{
          this.form=res.data
        })
      }
    },
    mounted(){
      var id = this.$route.params.id;

      if (id!=undefined){
        this.findById(id)
      }
    }
  }
</script>

<style scoped>
  .width270Height40{
    width: 600px;line-height:50px;float:left;margin-right:100px;
  }
</style>
